home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Tools - Objects
/
Macintosh Programmer’s Workshop
/
MPW 3.1
/
SADE 1.1
/
SADEScripts
/
HeapProcs
< prev
next >
Wrap
Text File
|
1990-12-13
|
3KB
|
129 lines
# Symbolic Application Debugging Environment 1.0 Final
#
# Copyright Apple Computer, Inc. 1987-1988
# All rights reserved.
###############################################################################
# validate a heap block, and report any problems
func checkblock (zone,lastblock,block,blocksize,blocktype,selfhandle);
define mp,mpvalue,stderrmsg := "Corrupt heap at %.8X";
if ((blocksize = 0)|((block+blocksize)>lastblock)|((blocksize & $01) = 1))
printf (stderrmsg,block);
printf (" invalid block size = %.8X\n",blocksize);
return (0);
end;
if (blocktype <> 0) then
if (blocktype < 0) then
mp := zone+selfhandle;
if ((selfhandle = 0)|((selfhandle & $01) = 1)|(mp < zone)|(mp>lastblock))
printf (stderrmsg,block);
printf (" invalid self relative handle = %.8X\n",selfhandle);
return (0);
end;
mpvalue := mp^;
if ((mpvalue & $0FFFFFFF) <> block+8) then
printf (stderrmsg,block);
printf (" master pointer for block at %.8X = %.8X\n",mp,(mpvalue &$0FFFFFFF));
printf ("Should = %.8X\n",block+8);
return (0);
end;
isLocked := ((mpvalue & $80000000) <> 0);
else
if (selfhandle <> zone) then
printf (stderrmsg,block);
printf (" zone pointer for block = %.8X\n",selfhandle);
printf ("Should = %.8X\n",zone);
return (0)
end;
end;
end;
return (1);
end;
# Display heap blocks
proc heapdisplay zonetodisplay;
define global valid
define global islocked
define nextblock,blocksize,lastblock,selfhandle,blocktype,blockstr;
if nargs = 0
zonetodisplay := thezone
end
nextblock := zonetodisplay+$34;
lastblock := zonetodisplay^;
printf ("location of heap: $%.8X\n",zonetodisplay);
printf ("last block in heap is: $%.8X\n",lastblock);
lastblock := lastblock + lastblock^;
while (nextblock < lastblock) do
blocksize := (nextblock^ & $00FFFFFF);
selfhandle := (nextblock+4)^;
blocktype := (nextblock^ & $F0000000);
leave If (checkblock (zonetodisplay,lastblock,nextblock,blocksize,blocktype,selfhandle) = 0);
if (blocktype < 0) then
if isLocked then
blockstr := "Locked"
else
blockstr := "Reloc";
end;
selfhandle := selfhandle+zonetodisplay;
elseif (blocktype = 0) then
blockstr := "Free"
selfhandle := 0;
else
blockstr := "NonReloc"
end;
printf ("location:$%.8X size:$%.8X %8P: $%.8X\n",nextblock,blocksize,blockstr,selfhandle);
nextblock := nextblock+blocksize;
end;
undefine valid
undefine islocked
end;
# displays the pointers on the free master pointer list for the current zone
proc showfreemp;
define nextmp;
nextmp := (thezone+8)^;
while (nextmp <> 0) do
printf ("freemp: $%.8X\n",nextmp);
nextmp := nextmp^;
end;
end;
define mpcount;
# counts the pointers on the free master pointer list for the specified zone
func countmp (zone);
define count,mp;
mp := (zone+8)^;
count := 0;
while (mp <> 0) do
count := count+1;
mp := mp^;
end;
return count;
end;
#displays various information about heaps
proc displayHeapInfo;
define firstfreemp :=(thezone+8)^
printf ("ApplZone: $%.8X\n",applzone);
printf ("SysZone: $%.8X\n",syszone);
printf ("TheZone: $%.8X\n",thezone);
printf ("First Free MP: $%.8X Number of free master pointers = %.8d\n",firstfreemp,countmp(TheZone));
printf ("Free Bytes: $%.8X\n",(thezone+12)^);
printf ("ApplLimit: $%.8X\n",ApplLimit);
end;